package com.xkh.demo1.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xkh.demo1.entity.Score;
import com.xkh.demo1.model.UserScoreVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ScoreMapper extends BaseMapper<Score> {

//    @Select("SELECT u.id as userId,s.id as scoreId,u.name as name,s.score as score " +
//            "FROM user_0 u,score s " +
//            "WHERE u.id = s.user_id AND u.id = #{userId}")
    @Select("SELECT u.id as userId,s.id as scoreId,u.name as name,s.score as score " +
            "FROM user_0 u LEFT JOIN score s ON u.id = s.user_id " +
            "WHERE u.id = #{userId}")
    List<UserScoreVo> selectScoreUser(@Param("userId") Integer userId);
}
